#include<cstdio>//uncle-lu
#include<vector>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

std::vector<int>edge[1000010];
long long int G[1000010], cnt[1000010], F[1000010];
int n;

void DP(int x, int fa)
{
	cnt[x] = 1;
	for (int i = 0; i < (int)edge[x].size(); i++)
	{
		int v = edge[x][i];
		if(v == fa)continue;
		DP(v, x);
		G[x] += (G[v] + cnt[v]);
		cnt[x] += cnt[v];
	}

	return ;
}

void DFS(int x, int fa)
{
	if(x != 1)
		F[x] = F[fa] + n - 2 * cnt[x];
	for (int i = 0; i < (int)edge[x].size(); i++) 
	{
		int v = edge[x][i];
		if(v == fa)continue;
		DFS(v, x);
	}
	return ;
}

int main()
{
	read(n);
	int x, y;
	for (int i = 1; i < n; i++) 
	{
		read(x); read(y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}

	DP(1, 0);

	F[1] = G[1];

	DFS(1, 0);

	long long int mx = F[1], sit = 1;
	for (int i = 1; i <= n; i++) 
		if(F[i] > mx)
		{
			mx = F[i];
			sit = i;
		}

	printf("%lld", sit);
	return 0;
}
